package laki.filter;

import java.io.IOException;

import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletResponse;

public class LogFilter implements Filter {

	@Override
	 public void doFilter(ServletRequest req, ServletResponse res,
	            FilterChain chain) throws IOException, ServletException {
	 
		  HttpServletResponse hsr = (HttpServletResponse) res;
		    hsr.setHeader("Cache-Control", "no-cache, no-store, must-revalidate"); // HTTP 1.1.
		    hsr.setHeader("Pragma", "no-cache"); // HTTP 1.0.
		    hsr.setDateHeader("Expires", 0); // Proxies.
		    chain.doFilter(req, res);
	    }
		@Override
	    public void init(FilterConfig config) throws ServletException {
	         
	        //Get init parameter
	        String testParam = config.getInitParameter("test-param");
	         
	        //Print the init parameter
	        System.out.println("Test Param: " + testParam);
	    }
		@Override
	    public void destroy() {
	        //add code to release any resource
	    }

}
